package com.example.demo;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;

@RestController
@RequestMapping("testapi")
public class ApiController {

  @Autowired
  private DemoFeign demoFeign;

  @GetMapping("func1")
  public Response01 func1() {
    GenericsFeignResultDecoder.setReturnType(Response01.class);
    Request01 request = new Request01();
    Response01 invoke = demoFeign.invoke(request);
    return invoke;
  }

  @GetMapping("func2")
  public Response02 func2() {
    GenericsFeignResultDecoder.setReturnType(Response02.class);
    Request02 request = new Request02();
    Response02 invoke = demoFeign.invoke(request);
    return invoke;
  }
  
  @GetMapping("func3")
  public Response01 func3() {
    Request01 request = new Request01();
    Response01 invoke = demoFeign.invoke1(request);
    return invoke;
  }

  @GetMapping("func4")
  public Response02 func4() {
    Request02 request = new Request02();
    Response02 invoke = demoFeign.invoke2(request);
    return invoke;
  }
  
  @GetMapping("func5")
  public List<List<Response02>> func5(@RequestBody JSONObject request) {
    List<List<Response02>> invoke = demoFeign.invoke3(request);
    return invoke;
  }
  
  @GetMapping("error")
  public Object error() {
    String invoke = demoFeign.error();
    return invoke;
  }
}
